import { createRouter, createWebHistory,createWebHashHistory} from 'vue-router'
import LayoutView from '../views/LayoutView.vue'

const router = createRouter({
  // 两种路由模式，最好用hash模式，因为history模式在刷新页面时会丢失路由信息
  // history: createWebHistory(import.meta.env.BASE_URL),
  history:createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: LayoutView,
      alias: '/layout',
      children:[
        {
          path:"/",
          name:'home',
          component:()=>import('../views/HomeView.vue')
        },
        {
          path:"/article",
          name:'article',
          component:()=>import('../views/ArticleView.vue')
        },
        {
          path:"/my",
          name:'my',
          component:()=>import('../views/MyView.vue')
        },
      ]
    },
    {
      path:"/:pathMatch(.*)*",
      name:'error',
      component:()=>import('../views/ErrorView.vue')
    },
    {
      path:"/login",
      name:'login',
      component:()=>import('../views/LoginView.vue')
    },
    {
      path:"/register",
      name:'register',
      component:()=>import('../views/RegisterView.vue')
    },
    {
      path:"/myself",
      name:'myself',
      component:()=>import('../views/MyselfView.vue')
    },
    {
      path:"/details",
      name:'details',
      component:()=>import('../views/DetailsView.vue')
    },
    {
      path:"/test",
      name:'test',
      component:()=>import('../views/TestView.vue')
    },
    {
      path:"/grade",
      name:'grade',
      component:()=>import('../views/GradeView.vue')
    },
    {
      path:'/setUserInfo',
      name:'setUserInfo',
      component:()=>import('../views/SetUserInfoView.vue')
    },
  ]
})

export default router
